home *** CD-ROM | disk | FTP | other *** search
- /* Radios.c */
-
- #include <Types.h>
- #include <Quickdraw.h>
- #include <Controls.h>
- #include <Dialogs.h>
- #include <Events.h>
- #include <Lists.h>
- #include <Menus.h>
- #include <Resources.h>
- #include <Sound.h>
- #include <TextEdit.h>
- #include <ToolUtils.h>
- #include <Appearance.h>
- #include <stdlib.h>
-
- #include "Globals.h"
- #include "ResourceDefs.h"
- #include "DoScrap.h"
- #include "Miscellany.h"
- #include "Scrolling.h"
- #include "ControlUtils.h"
- #include "Dispatcher.h"
- #include "DDocData.h"
- #include "EverythingEngine.h"
- #include "EverythingDoc.h"
- #include "Radios.h"
-
-
- static EverythingEngine* GetEngine (Radios* self);
-
- static void DoUndo (Radios* self);
- static void DoCut (Radios* self);
- static void DoCopy (Radios* self);
- static void DoPaste (Radios* self);
- static void DoClear (Radios* self);
- static void DoSelectAll (Radios* self);
- static void DoShowClipboard (Radios* self);
-
-
- //----------
- Radios* NewRadios ()
- {
- Radios* window;
-
- window = (Radios*)malloc (sizeof (Radios));
- Radios_Init (window);
- SetClassID (window, classRadios);
-
- return window;
- }
-
- //----------
- void DeleteRadios (
- Radios* window)
- {
- Radios_Free (window);
- free (window);
- }
-
- //----------
- void Radios_Create (
- AMDoc* inDoc,
- DDocData* inData)
- {
- Radios* winObj = NewRadios ();
-
- if (winObj != nil) {
- Radios_Open (winObj, inDoc, inData);
- }
- }
-
- //----------
- void Radios_Init (
- Radios* self)
- {
- }
-
- //----------
- void Radios_Free (
- Radios* self)
- {
- }
-
- //----------
- EverythingEngine* GetEngine (
- Radios* self)
- {
- return (EverythingEngine*) self->super.mDoc->mEngine;
- }
-
- /*----------*/
- void Radios_Open (
- Radios* self,
- AMDoc* inDoc,
- DDocData* inData)
- {
- WindowPtr window;
- Handle wftb;
-
- self->super.mDoc = inDoc;
- self->mData = inData;
- AddResponder ((AMSignaler*) self->mData, (AMResponder*) self);
-
- window = GetNewCWindow (WIND_Radios, nil, (WindowPtr) -1L);
- if (AMEngine_GetFilename (self->super.mDoc->mEngine) [0] != 0) {
- SetWTitle (window, AMEngine_GetFilename (self->super.mDoc->mEngine));
- }
- self->super.mWindow = window;
- ((EverythingDoc*)self->super.mDoc)->mRadiosPtr = window;
-
- SetWindowKind (window, 'AM');
- SetWRefCon (window, (long) self);
- SetPort (window);
- SetInfo (window);
-
- wftb = GetResource ('Wftb', WIND_Radios);
-
- CreateRootControl (window, &self->super.mRootControl);
-
- self->super.vScroll = nil;
- self->super.hScroll = nil;
-
-
- self->mRadioGroupGroupHandle = GetNewControl (CNTL_RadioGroupGroup, window);
- self->mStandard3Handle = GetNewControl (CNTL_Standard3, window);
- EmbedControl (self->mStandard3Handle, self->mRadioGroupGroupHandle);
- SetWindowItemFont (self->mStandard3Handle, wftb, 2);
-
- self->mGroupBoxHandle = GetNewControl (CNTL_GroupBox, window);
- SetWindowItemFont (self->mGroupBoxHandle, wftb, 3);
- self->mGroupGroupHandle = GetNewControl (CNTL_GroupGroup, window);
- EmbedControl (self->mGroupGroupHandle, self->mGroupBoxHandle);
- self->mGroupRadio1Handle = GetNewControl (CNTL_GroupRadio1, window);
- SetWindowItemFont (self->mGroupRadio1Handle, wftb, 5);
- EmbedControl (self->mGroupRadio1Handle, self->mGroupGroupHandle);
- self->mGroupRadio2Handle = GetNewControl (CNTL_GroupRadio2, window);
- SetWindowItemFont (self->mGroupRadio2Handle, wftb, 6);
- EmbedControl (self->mGroupRadio2Handle, self->mGroupGroupHandle);
- self->mGroupRadio3Handle = GetNewControl (CNTL_GroupRadio3, window);
- SetWindowItemFont (self->mGroupRadio3Handle, wftb, 7);
- EmbedControl (self->mGroupRadio3Handle, self->mGroupGroupHandle);
-
- self->mGraphic3BoxHandle = GetNewControl (CNTL_Graphic3Box, window);
- SetWindowItemFont (self->mGraphic3BoxHandle, wftb, 8);
- self->mGraphic3GroupHandle = GetNewControl (CNTL_Graphic3Group, window);
- EmbedControl (self->mGraphic3GroupHandle, self->mGraphic3BoxHandle);
- self->mStopHandle = GetNewControl (CNTL_Stop, window);
- EmbedControl (self->mStopHandle, self->mGraphic3GroupHandle);
- SetWindowItemFont (self->mStopHandle, wftb, 10);
- self->mGoHandle = GetNewControl (CNTL_Go, window);
- EmbedControl (self->mGoHandle, self->mGraphic3GroupHandle);
- SetWindowItemFont (self->mGoHandle, wftb, 11);
-
- self->mBevel3BoxHandle = GetNewControl (CNTL_Bevel3Box, window);
- SetWindowItemFont (self->mBevel3BoxHandle, wftb, 12);
- self->mBevel3GroupHandle = GetNewControl (CNTL_Bevel3Group, window);
- EmbedControl (self->mBevel3GroupHandle, self->mBevel3BoxHandle);
- self->mRadioButtonHandle = GetNewControl (CNTL_RadioButton, window);
- EmbedControl (self->mRadioButtonHandle, self->mBevel3GroupHandle);
- SetWindowItemFont (self->mRadioButtonHandle, wftb, 14);
- SetBevelButtonGraphicAlignment (self->mRadioButtonHandle, kControlBevelButtonAlignCenter, 0, 0);
- self->mRadioButton2Handle = GetNewControl (CNTL_RadioButton2, window);
- EmbedControl (self->mRadioButton2Handle, self->mBevel3GroupHandle);
- SetWindowItemFont (self->mRadioButton2Handle, wftb, 15);
- SetBevelButtonGraphicAlignment (self->mRadioButton2Handle, kControlBevelButtonAlignCenter, 0, 0);
-
- self->mTextBoxHandle = GetNewControl (CNTL_TextBox, window);
- SetWindowItemFont (self->mTextBoxHandle, wftb, 16);
- self->mTextGroupHandle = GetNewControl (CNTL_TextGroup, window);
- EmbedControl (self->mTextGroupHandle, self->mTextBoxHandle);
- self->mNameHandle = GetNewControl (CNTL_Name, window);
- EmbedControl (self->mNameHandle, self->mTextGroupHandle);
- SetWindowItemFont (self->mNameHandle, wftb, 18);
- self->mKindHandle = GetNewControl (CNTL_Kind, window);
- EmbedControl (self->mKindHandle, self->mTextGroupHandle);
- SetWindowItemFont (self->mKindHandle, wftb, 19);
- self->mSizeHandle = GetNewControl (CNTL_Size, window);
- EmbedControl (self->mSizeHandle, self->mTextGroupHandle);
- SetWindowItemFont (self->mSizeHandle, wftb, 20);
-
- AdvanceKeyboardFocus (window);
-
- ShowWindow (window);
- }
-
- /*----------*/
- void Radios_Close (
- Radios* self)
- {
- RemoveResponder ((AMSignaler*) self->mData, (AMResponder*) self);
-
- ((EverythingDoc*)self->super.mDoc)->mRadiosPtr = nil;
- SetInfo (nil);
- HideWindow (self->super.mWindow);
- DisposeWindow (self->super.mWindow);
-
- DeleteRadios (self);
- }
-
- /*----------*/
- void Radios_Track (
- Radios* self,
- ControlHandle whichControl,
- short whichPart,
- Point where)
- {
- Rect bounds;
- short newValue;
-
- if (whichControl == self->mRadioGroupGroupHandle) {
- if (TrackClick (whichControl, where) != 0) {
- SetRadioGroup (self->mData, GetControlValue (self->mRadioGroupGroupHandle));
- }
- }
- if (whichControl == self->mGroupGroupHandle) {
- if (TrackClick (whichControl, where) != 0) {
- SetGroup (self->mData, GetControlValue (self->mGroupGroupHandle));
- }
- }
- if (whichControl == self->mGraphic3GroupHandle) {
- if (TrackClick (whichControl, where) != 0) {
- SetGraphic (self->mData, GetControlValue (self->mGraphic3GroupHandle));
- }
- }
- if (whichControl == self->mBevel3GroupHandle) {
- if (TrackClick (whichControl, where) != 0) {
- SetBevel (self->mData, GetControlValue (self->mBevel3GroupHandle));
- }
- }
- if (whichControl == self->mTextGroupHandle) {
- if (TrackClick (whichControl, where) != 0) {
- SetText (self->mData, GetControlValue (self->mTextGroupHandle));
- }
- }
- }
-
- //----------
- void Radios_DataChanged (
- Radios* self,
- long inDataID)
- {
- if (inDataID == idRadioGroup) {
- SetControlValue (self->mRadioGroupGroupHandle, GetRadioGroup (self->mData));
- }
- if (inDataID == idGroup) {
- SetControlValue (self->mGroupGroupHandle, GetGroup (self->mData));
- }
- if (inDataID == idGraphic) {
- SetControlValue (self->mGraphic3GroupHandle, GetGraphic (self->mData));
- }
- if (inDataID == idBevel) {
- SetControlValue (self->mBevel3GroupHandle, GetBevel (self->mData));
- }
- if (inDataID == idText) {
- SetControlValue (self->mTextGroupHandle, GetText (self->mData));
- }
- }
-
- /*----------*/
- void Radios_MouseIn (
- Radios* self,
- Point where,
- short modifiers)
- {
- Rect bounds;
-
- }
-
- //----------
- void Radios_ExitCurField (
- Radios* self)
- {
- ControlHandle focus;
-
- GetKeyboardFocus (self->super.mWindow, &focus);
-
- if (focus == nil) {
- // nothing to exit
-
- }
- }
-
- /*----------*/
- void Radios_TypeIn (
- Radios* self,
- char ch)
- {
- ControlHandle focus;
- short keyCode;
-
- GetKeyboardFocus (self->super.mWindow, &focus);
-
- if ((ch == charEnter)
- || (ch == charReturn)) {
- Radios_ExitCurField (self); // Dispatch
- } else if (ch == charEsc) {
- } else if (ch == charTab) {
- AMWindow_DoTab ((AMWindow*) self, (curEvent.modifiers & optionKey) != 0);
- } else if (focus != nil) {
- keyCode = curEvent.message & keyCodeMask;
- HandleControlKey (focus, keyCode, ch, curEvent.modifiers);
- AMEngine_SetDirty (self->super.mDoc->mEngine);
- } else {
- SysBeep (1);
- }
- }
-
- /*----------*/
- void Radios_Resize (
- Radios* self)
- {
- /* application-specific code to resize items in window */
- }
-
- /*----------*/
- void Radios_Scroll (
- Radios* self,
- short newValue,
- short oldValue)
- {
- /* application-specific code to scroll window */
- if (gWhichScroll == self->super.vScroll) {
- } else { // horizontal
- }
- }
-
- //----------
- void DoUndo (
- Radios* self)
- {
- } // DoUndo
-
- //----------
- void DoCut (
- Radios* self)
- {
- TEHandle curTE = AMWindow_GetCurTE ((AMWindow*) self);
-
- if (curTE != nil) {
- TECut (curTE);
- AMEngine_SetDirty (self->super.mDoc->mEngine);
- scrapDirty = true;
- }
- } // DoCut
-
- //----------
- void DoCopy (
- Radios* self)
- {
- TEHandle curTE = AMWindow_GetCurTE ((AMWindow*) self);
-
- if (curTE != nil) {
- TECopy (curTE);
- scrapDirty = true;
- }
- } // DoCopy
-
- //----------
- void DoPaste (
- Radios* self)
- {
- TEHandle curTE = AMWindow_GetCurTE ((AMWindow*) self);
-
- if (curTE != nil) {
- TEPaste (curTE);
- AMEngine_SetDirty (self->super.mDoc->mEngine);
- }
- } // DoPaste
-
- //----------
- void DoClear (
- Radios* self)
- {
- TEHandle curTE = AMWindow_GetCurTE ((AMWindow*) self);
-
- if (curTE != nil) {
- TEDelete (curTE);
- AMEngine_SetDirty (self->super.mDoc->mEngine);
- }
- } // DoClear
-
- //----------
- void DoSelectAll (
- Radios* self)
- {
- TEHandle curTE = AMWindow_GetCurTE ((AMWindow*) self);
-
- if (curTE != nil) {
- TESetSelect (0, 32767, curTE);
- }
- } // DoSelectAll
-
- //----------
- void DoShowClipboard (
- Radios* self)
- {
- } // DoShowClipboard
-
- //----------
- Boolean Radios_DoCommand (
- Radios* self,
- long inCommand)
- {
- Boolean result = true;
-
- switch (inCommand) {
- case cmdUndo:
- DoUndo (self);
- break;
- case cmdCut:
- DoCut (self);
- break;
- case cmdCopy:
- DoCopy (self);
- break;
- case cmdPaste:
- DoPaste (self);
- break;
- case cmdClear:
- DoClear (self);
- break;
- case cmdSelectAll:
- DoSelectAll (self);
- break;
- case cmdShowClipboard:
- DoShowClipboard (self);
- break;
-
- default:
- result = false;
- } // switch
-
- return result;
- }
-